use std::{
    collections::HashMap,
    time::Instant
};

pub async fn get() {
    let url: String = "http://huoyan.cdn.myhayo.com/file/2020-09-03/00cff392177746506a3d572d16b0b353.txt".into();
    let mut urls: Vec<String> = Vec::new();
    urls.push(url.to_owned());
    urls.push(url.to_owned());
    urls.push(url.to_owned());

    // Tokio环境中，无法在子线程中使用reqwest
    let _i = urls.iter().any(|url| {
        let res = reqwest::blocking::get(url).unwrap();
        if res.status() == 200 {
            let text = res.text();
            if text.is_ok() {
                println!("{}", text.unwrap());
            }
        }
        println!("done.");
        true
    });
}

pub async fn test() {
    let start = Instant::now();
    let mut res = reqwest::get("http://ss.test.myhayo.com").await;
    for _ in 0..20 {
        res = reqwest::get("http://ss.test.myhayo.com").await;
    }
    println!("{:?}", res);
    println!("spend {:?}ms", start.elapsed().as_millis());
}